package dd.control;

import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;

import xml.Message;
import dd.model.Event;
import dd.model.Model;

/**
 * call when get TurnResponse this response tell the player that it is his turn to draw an edge in roundRobin type the
 * player get the ability to draw an edge
 */
public class TurnResponseController {

	public void process(Message response) {
		Model model = Model.getInstance();
		Event e = model.getEvent();
		Node update = response.contents.getFirstChild();
		NamedNodeMap map = update.getAttributes();
		String iscomplete = map.getNamedItem("completed").getNodeValue();
		// if all the edges have been added
		if (iscomplete.equals("true")) {
			e.setcomplete(true);
		} else {
			e.setcomplete(false);
			e.setIsYourTurn(true);
			model.getaef().repaint();
		}
	}
}
